window.onload = function(){
	var fn= sessionStorage.getItem("function")
	if(fn === 'Login'){
		$("#login").click()
	}
	if(fn === 'Register'){
		$("#regist").click()
	}
}
$("#login").click(function(){
    $("#logindiv").css("display","block")
    $("#rigistdiv").css("display","none")
    $(this).css("color","black")
    $("#regist").css("color","#c8c7c7")
})
$("#regist").click(function(){
    $("#logindiv").css("display","none")
    $("#rigistdiv").css("display","block")
    $("#login").css("color","#c8c7c7")
    $(this).css("color","black")
})
$("#account_input").focus(function(){
    $(this).css("border","1px solid red")
    $(this).css("background","#fcf2f3")
    $(this).css("paddingTop","20px")
    $(this).css("fontSize","18px")
    $(".AccountHint").css("display","none")
    $(".UserAccount").css("position","absolute")
    $(".UserAccount").css("fontSize","5px")
    $(".UserAccount").css("marginTop","-65px")
    $(".UserAccount").css("color","#a5a5a5")
})
$("#account_input").blur(function(){
    if(document.getElementById('account_input').value.length==0){
        $(".AccountHint").css("display","block")
        $(".UserAccount").css("position","absolute")
        $(".UserAccount").css("fontSize","15px")
        $(".UserAccount").css("marginTop","-39px")
        $(".UserAccount").css("marginLeft","22px")
        $(".UserAccount").css("letterSpacing","2px")
        $(".UserAccount").css("color","red")
        $(this).css("paddingTop","0px")
        $(this).css("fontSize","18px")
    }
    else{
        $(this).css("border","1px solid white")
        $(this).css("background","#f9f9f9")
    }
})
$("#Password_input").focus(function(){
    $(this).css("border","1px solid red")
    $(this).css("background","#fcf2f3")
    $(this).css("paddingTop","20px")
    $(this).css("fontSize","18px")
    $(".PasswordHint").css("display","none")
    $(".UserPassword").css("position","absolute")
    $(".UserPassword").css("fontSize","5px")
    $(".UserPassword").css("marginTop","-65px")
    $(".UserPassword").css("color","#a5a5a5")
})
$("#Password_input").blur(function(){
    if(document.getElementById('Password_input').value.length==0){
        $(".PasswordHint").css("display","block")
        $(".UserPassword").css("position","absolute")
        $(".UserPassword").css("fontSize","15px")
        $(".UserPassword").css("marginTop","-39px")
        $(".UserPassword").css("marginLeft","22px")
        $(".UserPassword").css("letterSpacing","2px")
        $(".UserPassword").css("color","red")
        $(this).css("paddingTop","0px")
        $(this).css("fontSize","18px")
    }
    else{
        $(this).css("border","1px solid white")
        $(this).css("background","#f9f9f9")
    }
})
$("#phone_input").focus(function(){
    $(this).css("border","1px solid red")
    $(this).css("background","#fcf2f3")
    $(this).css("borderLeft","none")
    $(this).css("paddingTop","20px")
    $(this).css("fontSize","18px")
    $(this).css("marginTop","-75px")
    $(this).css("height","60px")
    $(this).css("border-top-left-radius","0px")
    $(this).css("border-bottom-left-radius","0px")
    $(".PhoneHint").css("display","none")
    $(".UserPhone").css("position","absolute")
    $(".UserPhone").css("fontSize","5px")
    $(".UserPhone").css("marginTop","-60px")
    $(".UserPhone").css("color","#a5a5a5")
    $("#countryid").css("marginTop","-72px")
    $("#countryid").css("color","#a5a5a5")
    $("#countryid_number").css("color","#a5a5a5")
    $("#countryid").css("color","#a5a5a5")
    $("#countryid_number").css("color","#a5a5a5")
    $("#rigistdiv_phone_button").css("border","1px solid red")
    $("#rigistdiv_phone_button").css("borderRight","none")
    $("#rigistdiv_phone_button").css("background","#fcf2f3")
    $("#rigistdiv_phone_button").css("height","83px")
    $("#rigistdiv_phone_button").css("border-top-right-radius","0px")
    $("#rigistdiv_phone_button").css("border-bottom-right-radius","0px")
})
$("#phone_input").blur(function(){
    if(document.getElementById('phone_input').value.length==0){
        $(".PhoneHint").css("display","block")
        $(".UserPhone").css("position","absolute")
        $(".UserPhone").css("fontSize","15px")
        $(".UserPhone").css("marginTop","-50px")
        $(".UserPhone").css("marginLeft","170px")
        $(".UserPhone").css("letterSpacing","2px")
        $(".UserPhone").css("color","red")
        $("#phone_input").css("paddingTop","0px")
        $("#phone_input").css("marginTop","-73px")
        $("#phone_input").css("height","61.5px")
        $("#countryid").css("color","red")
        $("#countryid").css("marginTop","-55px")
        $("#countryid_number").css("color","red")
        $("#rigistdiv_phone_button").css("height","64px")
        $("#rigistdiv_phone_button").css("background","#fcf2f3")
    }
    else{
        $("#phone_input").css("border","0px")
        $("#phone_input").css("background","#f9f9f9")
        $("#countryid").css("color","#a5a5a5")
        $("#countryid_number").css("color","#a5a5a5")
        $("#rigistdiv_phone_button").css("border","0px")
        $("#rigistdiv_phone_button").css("background","#f9f9f9")
    }
})
$("#message_input").focus(function(){
    $(this).css("border","1px solid red")
    $(this).css("background","#fcf2f3")
    $(this).css("paddingTop","20px")
    $(this).css("fontSize","18px")
    $(".MessageHint").css("display","none")
    $(".UserMessage").css("position","absolute")
    $(".UserMessage").css("fontSize","5px")
    $(".UserMessage").css("marginTop","-65px")
    $(".UserMessage").css("color","#a5a5a5")
    $(".message_button").css("background","#fcf2f3")
    $(".message_button").css("marginTop","50px")
})
$("#message_input").blur(function(){
    if(document.getElementById('message_input').value.length==0){
        $(".MessageHint").css("display","block")
        $(".UserMessage").css("position","absolute")
        $(".UserMessage").css("fontSize","15px")
        $(".UserMessage").css("marginTop","-39px")
        $(".UserMessage").css("marginLeft","22px")
        $(".UserMessage").css("letterSpacing","2px")
        $(".UserMessage").css("color","red")
        $(this).css("paddingTop","0px")
        $(this).css("fontSize","18px")
        $(".message_button").css("marginTop","40px")
    }
    else{
        $(this).css("border","1px solid white")
        $(this).css("background","#f9f9f9")
        $(".message_button").css("background","#f9f9f9")
    }
})
var clock = '';
var nums = 10;
var btn;
function sendCode(thisBtn) {
    if(document.getElementById('phone_input').value.length==0){
        $(".PhoneHint").css("display","block")
        $(".UserPhone").css("position","absolute")
        $(".UserPhone").css("fontSize","15px")
        $(".UserPhone").css("marginTop","-50px")
        $(".UserPhone").css("marginLeft","170px")
        $(".UserPhone").css("letterSpacing","2px")
        $(".UserPhone").css("color","red")
        $("#phone_input").css("paddingTop","0px")
        $("#phone_input").css("border","1px solid red")
        $("#phone_input").css("borderLeft","0px")
        $("#phone_input").css("background","#fcf2f3")
        $("#phone_input").css("border-top-left-radius","0px")
        $("#phone_input").css("border-bottom-left-radius","0px")
        $("#phone_input").css("marginTop","-73px")
        $("#phone_input").css("height","61.5px")
        $("#countryid").css("color","red")
        $("#countryid").css("marginTop","-55px")
        $("#countryid_number").css("color","red")
        $("#rigistdiv_phone_button").css("border-top-right-radius","0px")
        $("#rigistdiv_phone_button").css("border-bottom-right-radius","0px")
        $("#rigistdiv_phone_button").css("height","64.5px")
        $("#rigistdiv_phone_button").css("background","#fcf2f3")
        $("#rigistdiv_phone_button").css("border","1px solid red")
        $("#rigistdiv_phone_button").css("borderRight","0px")
    }else{
        var phone = $('#phone_input').val();
        var regex = /^(13[0-9]{9})|(15[0-9]{9})|(17[0-9]{9})|(18[0-9]{9})|(19[0-9]{9})$/;
        if (!regex.test(phone)) {
            alert("请录入正确的手机号码！");
            $('#phone_input').focus();
            return false;
        }else{
            $("#rigistButton").css("background","#ff5d01")
            $(".message_button").css("marginLeft","-130px")
            btn = thisBtn;
            btn.disabled = true; //将按钮置为不可点击
            btn.value = nums + '秒后可重新获取';
            clock = setInterval(doLoop, 1000); //一秒执行一次
            return null;
        }
        
    }
}
function doLoop(){
    nums--;
    if (nums > 0) {
        btn.value = nums + '秒后可重新获取';
    } else {
        clearInterval(clock); //清除js定时器
        btn.disabled = false;
        btn.value = '获取验证码';
        nums = 10; //重置时间
    }
}
